﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Utils;
using Utils.DatabaseUtils;

namespace DCSLibrary
{
    public class PropertiesUI
    {
        public DataSet GetAll()
        {
            try
            {
                return SqlHelper.ExecuteDataset(Common.Conn, CommandType.StoredProcedure, "Properties_getall");
            }
            catch (Exception e)
            {
                throw new Exception(e.ToString());
            }
        }
        
        public DataSet GetByID(int PropertiesID)
        {
            try
            {
                return SqlHelper.ExecuteDataset(Common.Conn, "Properties_get", PropertiesID);
            }
            catch (Exception e)
            {
                throw new Exception(e.ToString());
            }
        }

        public DataSet GetByPropertyTypeName(string propertyTypeName)
        {
            try
            {
                return SqlHelper.ExecuteDataset(Common.Conn, "Properties_GetByTypeName", propertyTypeName);
            }
            catch (Exception e)
            {
                throw new Exception(e.ToString());
            }
        }

        public int DeleteByID(int PropertiesID)
        {
            try
            {
                return SqlHelper.ExecuteNonQuery(Common.Conn, "Properties_delete", PropertiesID);
            }
            catch (Exception e)
            {
                throw new Exception(e.ToString());
            }
        }

        public int Add(String PropertyTypeName, String PropertyName, String PropertyValue, bool IsEdit, bool IsActive)
        {
            try
            {
                return SqlHelper.ExecuteNonQuery(Common.Conn, "Properties_add", PropertyTypeName, PropertyName, PropertyValue, IsEdit, IsActive);
            }
            catch (Exception e)
            {
                throw new Exception(e.ToString());
            }
        }

        public int Update(int PropertyID, String PropertyTypeName, String PropertyName, String PropertyValue, bool IsEdit, bool IsActive)
        {
            try
            {
                return SqlHelper.ExecuteNonQuery(Common.Conn, "Properties_update", PropertyID, PropertyTypeName, PropertyName, PropertyValue, IsEdit, IsActive);
            }
            catch (Exception e)
            {
                throw new Exception(e.ToString());
            }
        }
    }
}
